#include "AppDelegate.h"
#include "Game.h"

USING_NS_CC;

const float ResolutionWidth = 800;
const float ResolutionHeight = 480;

AppDelegate::AppDelegate()
{
}

AppDelegate::~AppDelegate() 
{
}

bool AppDelegate::applicationDidFinishLaunching()
{
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
		glview = GLView::createWithRect("kxlol", Rect(0, 0, ResolutionWidth, ResolutionHeight));
#else
		glview = GLView::create("kxlol");
#endif
        director->setOpenGLView(glview);
    }
	glview->setDesignResolutionSize(ResolutionWidth, ResolutionHeight, ResolutionPolicy::EXACT_FIT);
	director->setAnimationInterval(1.0 / 60);
#if COCOS2D_DEBUG > 0
	director->setDisplayStats(true);
#endif`
	return Game::initialize();
}

// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
	Director::getInstance()->pause();
    Director::getInstance()->stopAnimation();
    // if you use SimpleAudioEngine, it must be pause
    // SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
    // if you use SimpleAudioEngine, it must resume here
    // SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
	Director::getInstance()->startAnimation();
	Director::getInstance()->resume();
}
